var ListIterator = /** @class */ (function () {
    function ListIterator(list) {
        this.list = list;
        this.index = 0;
    }
    ListIterator.prototype.first = function () {
        this.index = 0;
    };
    ListIterator.prototype.next = function () {
        this.index++;
    };
    ListIterator.prototype.hasNext = function () {
        return this.index < this.list.getSize() - 1;
    };
    ListIterator.prototype.isDone = function () {
        return this.index === this.list.getSize();
    };
    ListIterator.prototype.currentItem = function () {
        if (this.index < this.list.getSize()) {
            return this.list.getItemByIndex(this.index);
        }
        return null;
    };
    return ListIterator;
}());
var ListAggregate = /** @class */ (function () {
    function ListAggregate() {
        this.list = [];
    }
    ListAggregate.prototype.createIterator = function () {
        return new ListIterator(this);
    };
    ListAggregate.prototype.getSize = function () {
        return this.list.length;
    };
    ListAggregate.prototype.getItemByIndex = function (index) {
        return this.list[index];
    };
    ListAggregate.prototype.addItem = function (item) {
        this.list.push(item);
    };
    return ListAggregate;
}());
function main() {
    var aggregate = new ListAggregate();
    aggregate.addItem(2);
    aggregate.addItem(2);
    aggregate.addItem(3);
    aggregate.addItem(4);
    var it = aggregate.createIterator();
    while (!it.isDone()) {
        log(it.currentItem());
        it.next();
    }
}
main();
